<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>后台登录</title>
<link rel="stylesheet" type="text/css" href="./layui/css/layui.css" />
<link rel="stylesheet" type="text/css" href="./static/css/login.css" />
<script src="${pageContext.request.contextPath}/js/jquery-2.0.3.js"
	type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">
	$(function() {
		var code = null;
		//点击图片切换验证码
		$("#vcodeImg").click(function() {
			this.src = "get_cpacha?vl=4&w=150&h=40&t=" + new Date().getTime();
		
		});
		$("#vcode").focus(function(){
			$.ajax({
				url : "getcode", ////地址和springmvc中控制器地址一致
				type : "get", //提交方式
				data:{
					
				},
				//contentType : "application/json", //提交给控制的数据 格式
				success : function(data) {
					console.log("getcode:" + data);
					console.log(123);
					$("#op").val(data);
				}
			});
		});
	})
</script>
<script type="text/javascript">
$(function() {
	var errmsg="<%=request.getAttribute("errMsg")%>";
	alert(errmsg);
});
</script>



</head>

<body>
	<div class="m-login-bg">
		<div class="m-login">
			<h3>后台系统登录</h3>
			<div class="m-login-warp">

				<form class="layui-form" action="loginemp" method="post">
					<div class="layui-form-item">
						<input type="text" name="empno" id="empno" required
							lay-verify="required" placeholder="请输入工号" autocomplete="off"
							class="layui-input">
					</div>
					<div class="layui-form-item">
						<input type="password" name="emppwd" id="emppwd" required
							lay-verify="required" placeholder="请输入密码" autocomplete="off"
							class="layui-input">
					</div>

					<div class="layui-form-item">
						<select class="layui-select" name="status" id="status">
							<!-- <option hidden="-请选择职位-" readonly>-请选择职位-</option> -->
							<option value="0">-员工-</option>
							<option value="1">-管理员-</option>
						</select>
					</div>

					<div class="layui-form-item">
						<input class="layui-input" name="vcode" id="vcode" type="text"
							placeholder="请输入验证码" style="width: 185px; display: inline;">
						<img title="点击图片切换验证码" id="vcodeImg"
							src="get_cpacha?vl=4&w=150&h=40">
					</div>

					<div class="layui-form-item m-login-btn">
						<div class="layui-inline">
							<!-- <button id="btn" type="button" class="layui-btn layui-btn-normal">登录</button> -->
							<button class="layui-btn" lay-submit lay-filter="login">登录</button>
						</div>
						<div class="layui-inline">
							<button type="reset" class="layui-btn layui-btn-primary">取消</button>
						</div>
					</div>

				</form>
			</div>
			<p class="copyright">Copyright 2020-2021 by XIAODU</p>
			<input type="hidden" name="op" id="op">
		</div>
	</div>
	<script src="./layui/layui.js" type="text/javascript" charset="utf-8"></script>

	<script type="text/javascript">
		function flushCheckCode(obj) {
			obj.src = (obj.src + '?' + new Date())
		}
	</script>

	<script>
		
		layui.use('form', function() {
			var form = layui.form;
			form.on('submit(login)', function(data) {
				var empno = $("#empno").val();
				var emppwd = $("#emppwd").val();
				//验证码字母改为大写
				var yzm = $("#op").val();
				console.log("yzm:" + yzm);
				console.log(empno);
				var power = $("#power").val();
				console.log(power);
				var vcode = $("#vcode").val();
				console.log(vcode);

				if (empno == null || empno.trim() == "") {
					alert("用户名不能为空!");
					return;
				}
				if (emppwd == null || emppwd.trim() == "") {
					alert("密码不能为空!");
					return;
				}
				if (vcode == null || vcode.trim() == "") {
					alert("验证码不能为空!");
					return false;
				} else if (vcode != yzm) {
					alert("验证码输入错误!");
					return false;
				}

				return true;
			});

		});
	</script>

</body>

</html>
